<template>
    <el-container>
        <!-- {{ lessorsAccount }} -->

        <el-header height="100px"
            ><el-avatar
                id="img"
                :src="
                    'http://localhost:3000/images/' +
                    lessorsAccount[0].imagesName
                "
            ></el-avatar
            ><span id="welcome">
                欢迎[{{ lessorsAccount[0].account }}]出租方
            </span>
            <span id="leaveBtn" @click="leaveBtn" style="font-weight: 20px"
                >退出</span
            ></el-header
        >
        <el-container>
            <el-aside width="200px">
                <el-menu
                    id="el-menu"
                    default-active="2"
                    class="el-menu-vertical-demo"
                    @open="handleOpen"
                    @close="handleClose"
                    background-color="#545c64"
                    text-color="#fff"
                    active-text-color="#ffd04b"
                    :router="true"
                >
                    <!-- :router="true"// element提供的方法 默认false,改成true后可以设置index为路由跳转的路径 -->
                    <el-submenu index="1">
                        <template slot="title">
                            <i class="el-icon-user-solid"></i>
                            <span>个人中心</span>
                        </template>
                        <el-menu-item-group>
                            <el-menu-item index="/system/lessorsList"
                                >个人信息</el-menu-item
                            >
                        </el-menu-item-group>
                    </el-submenu>
                    <el-submenu index="2">
                        <template slot="title">
                            <i class="el-icon-s-custom"></i>
                            <span slot="title">订单管理</span>
                        </template>
                        <el-menu-item-group>
                            <el-menu-item index="/system/lookOrders"
                                >租赁订单</el-menu-item
                            >
                        </el-menu-item-group>
                    </el-submenu>
                    <el-submenu index="4">
                        <template slot="title">
                            <i class="el-icon-menu"></i>
                            <span slot="title">车位管理</span>
                        </template>
                        <el-menu-item-group>
                            <el-menu-item index="/system/parkingsList"
                                >所有车位</el-menu-item
                            >
                            <el-menu-item index="/system/addParkings"
                                >添加车位</el-menu-item
                            >
                            <el-menu-item index="/system/groundingParkings"
                                >车位上/下架</el-menu-item
                            >
                        </el-menu-item-group>
                    </el-submenu>
                </el-menu>
            </el-aside>
            <el-main>
                <keep-alive>
                    <router-view v-if="$route.meta.keepAlive"></router-view>
                </keep-alive>
                <router-view v-if="!$route.meta.keepAlive"></router-view>
            </el-main>
        </el-container>
        <el-footer height="100px">Footer</el-footer>
    </el-container>
</template>

<script>
import { createNamespacedHelpers } from "vuex";
const { mapActions, mapState } = createNamespacedHelpers("lessors");
export default {
    data() {
        return {};
    },
    async mounted() {
        const lessorsData = await this.isLogin();
        console.log(lessorsData, this.lessorsAccount[0].imagesName);
    },
    methods: {
        ...mapActions(["isLogin"]),
        handleOpen(key, keyPath) {
            console.log(key, keyPath);
        },
        handleClose(key, keyPath) {
            console.log(key, keyPath);
        },
        //点击退出清除token
        leaveBtn() {
            localStorage.removeItem("token");
            this.$router.push("/lessorsLogin");
        },
    },
    computed: {
        ...mapState(["lessorsAccount"]),
    },
};
</script>

<style lang="scss">
#img {
    width: 80px;
    height: 80px;
    vertical-align: middle;
}
#el-menu {
    border: 0px;
    height: 100%;
}
#header {
    display: flex;
    justify-content: space-between;
}
.el-header {
    color: #333;
    text-align: center;
    padding: 0;
    line-height: 100px;
    // font-size: 30px;
    font-weight: bold;
    background: linear-gradient(
        30deg,
        rgba(255, 0, 0, 0.5),
        rgba(255, 255, 0, 0.5) 100%
    );
}
#welcome {
    text-align: center;
    line-height: 100px;
    font-size: 30px;
    padding-left: 400px;
}
#leaveBtn {
    padding-left: 500px;
    // margin-right: 0px !important;
}
.el-footer {
    color: #333;
    text-align: center;
    padding: 0;
    line-height: 100px;
    font-size: 30px;
    font-weight: bold;
    background: linear-gradient(
        30deg,
        rgba(255, 0, 0, 0.5),
        rgba(255, 255, 0, 0.5) 100%
    );
}
.el-aside {
    background-color: #d3dce6;
    color: #333;
    text-align: center;
    // line-height: 200px;
}

.el-main {
    background-color: #e9eef3;
    color: #333;
    text-align: center;
    // line-height: 160px;
}
.el-container {
    height: 100vh;
}
body > .el-container {
    margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
    line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
    line-height: 320px;
}
</style>